package boardgamer.yavalath.common;

import boardgamer.common.net.PlayerState;
import com.google.common.base.Objects;

import static com.google.common.base.Preconditions.checkNotNull;

public class YavalathPlayerState implements PlayerState {

  private static final long serialVersionUID = -3775985016107407545L;

  public enum PlayerColor {
    RED("Red"),
    ORANGE("Orange"),
    YELLOW("Yellow"),
    CHARTREUSE("Chartreuse"),
    AQUA("Aqua"),
    BLUE("Blue"),
    MAGENTA("Magenta"),
    BROWN("Brown"),
    WHITE("White");
    
    private final String renderedName;
    
    private PlayerColor(String renderedName) {
      this.renderedName = checkNotNull(renderedName, "renderedName");
    }
    
    public String getRenderedName() {
      return renderedName;
    }
  }

  public enum PlayerMode {
    HUMAN,
    AI,
    CLOSED
  }

  private final PlayerColor color;
  private final PlayerMode mode;

  public YavalathPlayerState(PlayerColor color, PlayerMode mode) {
    this.color = checkNotNull(color, "color");
    this.mode = checkNotNull(mode, "mode");
  }

  public PlayerColor getColor() {
    return color;
  }

  public PlayerMode getMode() {
    return mode;
  }

  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof YavalathPlayerState)) {
      return false;
    }

    YavalathPlayerState that = (YavalathPlayerState) obj;
    return Objects.equal(this.color, that.color)
        && Objects.equal(this.mode, that.mode);
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(color, mode);
  }

  @Override
  public String toString() {
    return Objects.toStringHelper(this)
        .add("color", color)
        .add("mode", mode)
        .toString();
  }
}
